<!--待签约-->
<template>
  <div>
    <el-form :model="checkForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="办理结果" prop="approveStatus"  :rules="[{ required: true, message: '请选择办理结果', trigger: 'change' }]">
        <el-radio-group v-model="checkForm.approveStatus" @change="handleChange">
          <el-radio label="7" class="red">转派</el-radio>
          <el-radio label="3" class="red">退件</el-radio>
          <el-radio label="5" class="red">拒件</el-radio>
          <el-radio label="9" class="red">通过</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="转派" prop="checkerId" v-if="checkForm.approveStatus === '7'" required>
        <el-select v-model="checkForm.checkerId" placeholder="请选择">
          <el-option v-for="item in sendCheckPersons" :key="item.id" :label="item.nameAndMobile" :value="item.id"> </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="反馈信息" prop="opinion">
        <el-input type="textarea" :rows="7" v-model="checkForm.opinion" style="width: 300px"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm(checkForm)"  v-loading="loading">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { signCheck, listRedePloyUser } from '@/api/project';
export default {
  props: {
    projectId: undefined,
    taskId: undefined,
  },
  data() {
    return {
      checkForm: {
        approveStatus: undefined,
        checkerId: undefined,
        opinion: undefined,
        projectId: undefined,
      },
      sendCheckPersons: [],
      supplyUser: [],
      value: '',
      loading: false
    };
  },
  created() {
    // 初始化数据
    this.listRedePloyUser();
  },
  methods: {
    submitForm() {(this.checkForm.projectId = this.projectId),
        (this.checkForm.taskId = this.taskId),
        this.$confirm('你确定要提交吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          // 开始提交信息
          this.loading = true;
          signCheck(this.checkForm).then((data) => {
            this.loading = false;
               this.$notify.success({
                title: '成功',
                message: '操作成功'
              })
            this.$store.dispatch("tagsView/delView", this.$route);
            this.$router.go(-1);
          }).catch(() => {
            this.loading = false;
          })
        });
    },
    listRedePloyUser() {
      // 查询数据 构造页面
      listRedePloyUser('合同岗').then((data) => {
        this.sendCheckPersons = data.data;
        console.log('响应数据:%o', data);
      });
    },
    handleChange(node) {
      this.restForm();
      this.checkForm.approveStatus = node;
    },

    restForm() {
      this.checkForm = {
        opinion: undefined,
        checkerId: undefined,
        approveStatus: undefined,
      };
    },
  },
};
</script>
